package zengqiang;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class loginServlet implements Servlet {
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        //获取请求参数,还有其他各种获取方式
        String username = servletRequest.getParameter("username");
        System.out.println(username);
        //如果同一个属性名称，对应提交有多个，此时下面的获取方式可以获取出一个数组，上面的则只能获取第一个
        String[] interestings = servletRequest.getParameterValues("interesting");
        //
        HttpServletRequest httpServletRequest= (HttpServletRequest) servletRequest;
        httpServletRequest.getRequestURI();//除去ip和端口的地址，整个叫url
        httpServletRequest.getMethod();
        httpServletRequest.getQueryString();//获取get请求的参数字符串
        httpServletRequest.getServletPath();//获取serlvet的名称  例如此时结果是：/loginServlet

    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
